package com.i18n.utils;

import java.io.UnsupportedEncodingException;
import java.util.Locale;
import java.util.ResourceBundle;

/**
 * @author WuLiangHang
 */
public class MessageUtils {
    private static String baseName = "res";
    private static Locale locale;

    public static String getText(String key) throws UnsupportedEncodingException {
        return  new String(ResourceBundle.getBundle(baseName, locale).getString(key).getBytes("ISO-8859-1"), "UTF-8");
    }

    public static Locale getLocale() {
        return locale;
    }

    public static void setLocale(Locale locale) {
        MessageUtils.locale = locale;
    }
}
